<?php

	class WS_LoginCon {
		
		private $DBADMIN;
		private $HASHID;
		
		public function __construct() {

			$this->DBADMIN 	= new WS_LoginMod();
			$this->HASHID 	= sha1(time());

		}
		
		public function login($strUsername, $strPassword, $strRemember) {

			$query = $this->DBADMIN->login($strUsername, $strPassword);

			if ( empty($query) ) {

				$result = array('WB_Warning' => warning(IN_USERPASS));

			}

			elseif ( $query['is_deleted'] != 'N' ) {

				$result = array('WB_Warning' => warning(USER_DEAC));

			}

			else {
				
				if ( !empty($strRemember) && $strRemember == 'on' ) {
					setcookie('WB_Cookie', $query['user_idPK'] . '-' . $this->HASHID, time()+2592000); // One Month before expired
					setcookie('WB_Account', $query['account_type'], time()+2592000); // One Month before expired
				}
				
				$admin_name 	= $query['last_name'] . ', ' . $query['first_name'] . ' ' . substr($query['middle_name'], 0, 1) . '.';
				$result = array('WB_Login' 		=> 'Y',
								'WB_LogUser' 	=> $admin_name,
								'WB_LogName' 	=> $query['first_name'],
							 	'WB_UserID' 	=> $query['user_idPK'],
							 	'WB_AccNo' 		=> $query['account_no'],
							 	'WB_AccType' 	=> $query['account_type'],
								'WB_Hash'		=> $this->HASHID
							    );

			}

			return $result;

		}
		
	}
?>